import { Dimensions, Linking, Platform } from 'react-native'

const SCREEN_WIDTH = Dimensions.get('window').width
const SCREEN_HEIGHT = Dimensions.get('window').height
const X_WIDTH = 375
const X_HEIGHT = 812

export const isIOS = Platform.OS === 'ios'
export const isAndroid = Platform.OS === 'android'

export function isIphoneX() {
  return (
    isIOS && (
      ((SCREEN_HEIGHT === 812 || SCREEN_WIDTH === 812) || (SCREEN_HEIGHT === 896 || SCREEN_WIDTH === 896))
      || ((SCREEN_HEIGHT === 844 || SCREEN_WIDTH === 844) || (SCREEN_HEIGHT === 926 || SCREEN_WIDTH === 926))
      || ((SCREEN_HEIGHT === X_HEIGHT && SCREEN_WIDTH === X_WIDTH)
        || (SCREEN_HEIGHT === X_WIDTH && SCREEN_WIDTH === X_HEIGHT))
    )
  )
}

export function openAppStore() {
  if (isAndroid) {
    Linking.openURL('market://details?id=com.pier88health.nerivio')
  } else {
    // TODO 需要发布之后才允许id
    Linking.openURL('itms-apps://itunes.apple.com/us/app/idtest?mt=8')
  }
}
